package com.yenlien.traceyun.business.service.rest.usercenter;

import com.alibaba.fastjson.JSONObject;
import com.yenlien.traceyun.business.bean.RestURL;
import com.yenlien.traceyun.business.service.rest.RestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

/**
 * Created by LiuSha on 2020/7/22.
 */
@Service
public class CompanyRestService {
    @Autowired
    private RestService restService;

    public Object findByList(JSONObject jsonObject) {
        return restService.postJson(RestURL.USERCENTER + "company/findByList", jsonObject);
    }

    public Object findById(String id) {
        return restService.getJson(RestURL.USERCENTER + "company/findById/" + id);
    }

    public Object findParentById(String id) {
        return restService.getJson(RestURL.USERCENTER + "company/findParentById/" + id);
    }

    public Object save(Map<String, Object> map, List<MultipartFile> files) {
        return restService.postForm(RestURL.USERCENTER + "company/save", map, files);
    }


    public Object save2(JSONObject jsonObject) {
        return restService.postJson(RestURL.USERCENTER + "company/save2", jsonObject);
    }



    public Object update(Map<String, Object> map, List<MultipartFile> files) {
        return restService.postForm(RestURL.USERCENTER + "company/update", map, files);
    }

    public Object delete(String id) {
        return restService.getJson(RestURL.USERCENTER + "company/delete/" + id);
    }

    /**
     * 企业审核
     *
     * @param jsonObject
     * @return
     */
    public Object examined(JSONObject jsonObject) {
        return restService.postJson(RestURL.USERCENTER + "company/examined", jsonObject);
    }

    /**
     * 企业审核列表
     *
     * @return
     */
    public Object examinedlist() {
        return restService.getJson(RestURL.USERCENTER + "company/examinedlist");
    }

    /**
     * 根据type加载企业
     *
     * @param type
     * @return
     */
    public Object companyType(String type) {
        return restService.getJson(RestURL.USERCENTER + "company/findByType/" + type);
    }

    /**
     * 获取子企业
     *
     * @return
     */
    public Object getchild(String companyId) {
        return restService.getJson(RestURL.USERCENTER + "company/get/child/" + companyId);
    }

    public Object plantCompany(String companyId) {
        return restService.getJson(RestURL.USERCENTER + "company/get/plantCompany/" + companyId);
    }
}
